import reader

class AbstractSexpr(object):
    @staticmethod
    def readFromString (strToParse):
        return reader.pSexpr.match(strToParse)

class Void(AbstractSexpr):
    def __init__(self):
        pass
    def __str__(self):
        return 'Void'

class Nil(AbstractSexpr):
    def __init__(self):
        pass
    def __str__(self):
        return '()'

class Boolean(AbstractSexpr):
    def __init__(self, val):
        self.val = val
    def __str__(self):
        if(self.val):
            return '#t'
        else:
            return '#f'

class Char(AbstractSexpr):
    def __init__(self, val):
        self.val = val;
    def __str__(self):
        return str(self.val)
    
class AbstractNumber(AbstractSexpr):
    def __init__(self, val):
        self.val = val;
    def __str__(self):
        return str(self.val)
    
class Integer(AbstractNumber):
    def __init__(self, val):
        super(Integer,self).__init__(val)
    def __str__(self):
        return str(self.val)
    
class Fraction(AbstractNumber):
    def __init__(self, val):
        super(Fraction,self).__init__(val)
    def __str__(self):
        return str(self.val)
    
class String(AbstractSexpr):
    def __init__(self, val):
        self.val = val;
    def __str__(self):
        return '"' + str(self.val) + '"'
    
class Symbol(AbstractSexpr):
    def __init__(self, val):
        self.val = val;
    def __str__(self):
        return str(self.val)
    
class Pair(AbstractSexpr):
    def __init__(self, val1,val2):
        self.val1 = val1;
        self.val2 = val2;
    def __str__(self):
        return "(" + str(self.val1) + " " + str(self.val2) + ")"
    def car(self):
        return self.val1
    def cdr(self):
        return self.val2
    
class Vector(AbstractSexpr):
    def __init__(self, vals):
        self.vals = vals;
    def __str__(self):
        return str(self.vals)
    
